package com.hualude.roadsign.utils;

/**
 * Created by ding on 2017/3/6.
 */

import com.lowagie.text.*;
import com.lowagie.text.Font;

import java.awt.*;
import java.io.IOException;

public class WordCreatUtil {

    //生成表头
    public Cell generateHeadCell(String content,int rowspan,int colspan,int isColor) throws DocumentException, IOException {

        Paragraph c = new Paragraph(content, new Font(Font.NORMAL, 10,
                Font.BOLD, Color.BLACK));
        Cell cell = new Cell(c);
        if(isColor==1)
            cell.setBackgroundColor(new Color(234, 234, 234));
        cell.setColspan(colspan);
        cell.setRowspan(rowspan);
        cell.setVerticalAlignment(1);
        cell.setHorizontalAlignment(1);
        return cell;
    }

    //生成Cell，content内容，rowspan跨几行,colspan跨几列
    public Cell generateNormalCell(String content,int rowspan,int colspan,int fontSize) throws DocumentException, IOException {
        Paragraph c = new Paragraph(content, new Font(Font.NORMAL, fontSize,
                Font.NORMAL, Color.BLACK));
        Cell cell = new Cell(c);
        cell.setRowspan(rowspan);
        cell.setColspan(colspan);
        cell.setVerticalAlignment(1);
        cell.setHorizontalAlignment(1);
        return cell;
    }
    //左对齐
    public Cell generateLeftCell(String content,int rowspan,int colspan,int fontSize) throws DocumentException, IOException {
        Paragraph c = new Paragraph(content, new Font(Font.NORMAL, fontSize,
                Font.NORMAL, Color.BLACK));
        Cell cell = new Cell(c);
        cell.setRowspan(rowspan);
        cell.setColspan(colspan);
        cell.setVerticalAlignment(1);
        cell.setHorizontalAlignment(3);
        return cell;
    }

    public Cell generateBottomCell(String content,int rowspan,int colspan) throws BadElementException {
        Paragraph c = new Paragraph(content,  new Font(Font.SYMBOL, 11,
                Font.NORMAL, Color.BLUE));
        Cell cell = new Cell(c);
        cell.setBorderColor(Color.white);;
        cell.setRowspan(rowspan);
        cell.setColspan(colspan);
        cell.setVerticalAlignment(1);
        cell.setHorizontalAlignment(3);
        return cell;
    }

}
